module.exports = {
    addLoadingLayer(addNode){
        if (addNode) {
            var w = cc.view.getVisibleSize().width;
            var h = cc.view.getVisibleSize().height;
            cc.loader.loadRes("prefab/LoadingLayer", function (err, prefab) {
                if (!err) {
                    var layer = cc.instantiate(prefab);
                    layer.x = 0;
                    layer.y = 0;
                    addNode.addChild(layer);
                }
            });
        }
    },
    addTipsDialog(str, okCb, closeCB){
        cc.loader.loadRes("prefab/TipsDialog", function (err, prefab) {
            if (!err) {
                var scene = cc.director.getScene();
                var w = cc.view.getVisibleSize().width;
                var h = cc.view.getVisibleSize().height;
                var layer = cc.instantiate(prefab);
                layer.x = w / 2;
                layer.y = h / 2;
                scene.addChild(layer);

                var script = layer.getComponent("TipsDialog");
                if (script) {
                    script.setString(str);
                    if (okCb) {
                        script.setOkCallBack(okCb);
                    }
                    if (closeCB) {
                        script.setCloseCallBack(closeCB);
                    }
                }
            }
        });
    },
}